<?php
get_header();
global $post;
$author =  get_the_author_meta('nickname',$post->post_author);

$img = get_the_post_thumbnail_url($post->ID,'full');
echo '<style> main .page-banner { background-image: url("'.$img.'");}</style>';
?>
<main class="main_content">
	<?php get_template_part('parts/content/page','banner');?>
    <article class="single-content container py-5">
        <p class="text-muted">
            <small class="mr-3"><i class="fa fa-user mr-1"></i><?php echo $author;?></small>
            <small class="mr-3"><i class="fa fa-folder mr-1"></i><?php foreach (get_the_category() as $cat) {echo $cat->name . " ";};?></small>
            <small class="mr-3"><i class="fa fa-eye mr-1"></i><?php atom_views(null,null);?></small>
        </p>
        <?php echo $post->post_content;?>
        <div class="single-share my-5 d-flex align-items-baseline">
            <div class="social-share-title font-weight-bold">
                分享到：
            </div>
            <span class="mr-2 border p-1 social-item rounded weibo"><i class="fa fa-weibo fw"></i></span>
            <span class="mr-2 border p-1 social-item rounded wechat" data-toggle="tooltip" data-placement="top" title="微信号:Kyurichiyu"><i class="fa fa-wechat fw"></i></span>
            <span class="mr-2 border p-1 social-item rounded qq"><i class="fa fa-qq fw"></i></span>
            <span class="mr-2 border p-1 social-item rounded linked"><i class="fa fa-linkedin fw"></i></span>
            <span class="mr-2 border p-1 social-item rounded facebook"><i class="fa fa-facebook fw"></i></span>
            <span class="mr-2 border p-1 social-item rounded twitter"><i class="fa fa-twitter fw"></i></span>
        </div>
        <div class="post-navigation border-bottom pb-3">
		    <?php the_post_navigation([
		            'prev_text' => __("<span class='mr-1 fa fa-angle-left'></span>上一篇",'wdstar'),
		            'next_text' => __("下一篇<span class='ml-1 fa fa-angle-right'></span>",'wdstar'),
            ]);?>
        </div>
    </article>
    <section class="post-relate container pb-md-5 mb-5">
        <h3 class="font-weight-normal mb-4"><?php _e('相关文章','wdstar');?></h3>
        <div class="row no-gutters flex-md-nowrap">
            <?php
            query_posts([
                "orderby" => "rand",
                "posts_per_page" =>  4,
                "category_name" => "blog",
                "post__not_in"  => [$post->ID],
            ]);
                while(have_posts()) : the_post();
            ?>
            <div class="col-md-3 mr-md-1 mb-md-0 mb-3">
                <div class="card category-item border-0">
                    <a href="<?php the_permalink()?>" class="card-img position-relative">
                        <div class="list-date position-absolute d-flex flex-wrap flex-column text-center">
                            <time class="day"><?php the_time('d');?></time>
                            <time class="month"><?php the_time('m');?>月</time>
                        </div>
                        <img src="<?php the_post_thumbnail_url('category');?>" class="card-img-top rounded-0" alt="<?php the_title_attribute()?>">
                    </a>
                    <div class="card-body bg-grey">
                        <a class="card-title" href="<?php the_permalink();?>"><h5 class="text-truncate" title="<?php the_title_attribute()?>"><?php the_title()?></h5></a>
                        <p class="text-muted">
                            <small class="mr-3"><i class="fa fa-calendar fw mr-1"></i> <?php the_time("Y-m-d");?></small>
                            <small class="mr-3"><i class="fa fa-eye fw mr-1"></i><?php echo atom_views(null,null);?></small>
                            <small><i class="fa fa-comments fw mr-1"></i><?php comments_number();?></p></small>
                    </div>
                </div>
            </div>
            <?php endwhile;wp_reset_query();?>
        </div>
    </section>
</main>
<?php get_footer(); ?>
